#!/bin/bash

APPLICATION_NAME=sim-cert-paas
SERVICE_NAME=cert-paas-server

pid=`ps -ef | grep $APPLICATION_NAME | grep -v grep | awk '{print $2}'`
if [ -n "$pid" ]; then
    echo stop $SERVICE_NAME process: $pid
    kill -9 $pid
fi

pid=`ps -ef | grep $APPLICATION_NAME | grep -v grep | awk '{print $2}'`
while [ -n "$pid" ]
do
    sleep 0.1s
    pid=`ps -ef | grep $APPLICATION_NAME | grep -v grep | awk '{print $2}'`
done
echo now, $SERVICE_NAME is not run!